﻿#region

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Client.Presentation;

#endregion

namespace Lab.WindowsFormUI {
    public partial class Form1 : Form, IClientView {
        public Form1() {
            InitializeComponent();
            new ClientClass(this);
        }

        private int Number;

        public event Action OnAddEmployer;
        public event Action OnAddApplicant;
        public event Action OnAddSkill;
        public event Action OnAddVacancy;

        public event Action OnGetEmployer;
        public event Action OnGetApplicant;
        public event Action OnGetSkill;
        public event Action OnGetVacancy;

        public event Action OnMakeDeal;
        public event Action OnGetDeal;

        public string ActionMessage {
            set { actionMessage.Text = value; }
        }

        public string EmployerName {
            set { textBox1.Text = value; }
            get { return textBox1.Text; }
        }

        public string EmployerAddress {
            set { textBox2.Text = value; }
            get { return textBox2.Text; }
        }

        public string EmployerTelephone {
            set { textBox3.Text = value; }
            get { return textBox3.Text; }
        }

        public string EmployerActivity {
            set { textBox4.Text = value; }
            get { return textBox4.Text; }
        }

        public string ApplicantName {
            set { textBox1.Text = value; }
            get { return textBox1.Text; }
        }

        public string ApplicantMidName {
            set { textBox2.Text = value; }
            get { return textBox2.Text; }
        }

        public string ApplicantSurname {
            set { textBox3.Text = value; }
            get { return textBox3.Text; }
        }

        public string ApplicantActivity {
            set { textBox4.Text = value; }
            get { return textBox4.Text; }
        }

        public string ApplicantSkills {
            set { textBox5.Text = value; }
            get { return textBox5.Text; }
        }

        public string ApplicantResidence {
            set { textBox6.Text = value; }
            get { return textBox6.Text; }
        }

        public string SkillsDescripton {
            set { textBox1.Text = value; }
            get { return textBox1.Text; }
        }

        public string VacancyName {
            set { textBox1.Text = value; }
            get { return textBox1.Text; }
        }

        public string VacancyOpenDate {
            set { textBox2.Text = value; }
            get { return textBox2.Text; }
        }

        public string VacancyLocation {
            set { textBox3.Text = value; }
            get { return textBox3.Text; }
        }

        public string VacancySalary {
            set { textBox4.Text = value; }
            get { return textBox4.Text; }
        }

        public string VacancySkills {
            set { textBox5.Text = value; }
            get { return textBox5.Text; }
        }

        public string VacancyActivity {
            set { textBox6.Text = value; }
            get { return textBox6.Text; }
        }

        public string VacancyEmployer {
            set { textBox7.Text = value; }
            get { return textBox7.Text; }
        }

        public string DealApplicant {
            get { return textBox1.Text; }
            set { textBox1.Text = value; }
        }

        public string DealEmployer {
            get { return textBox2.Text; }
            set { textBox2.Text = value; }
        }

        public string DealVacancy {
            get { return textBox3.Text; }
            set { textBox3.Text = value; }
        }

        public int ListNumber {
            set { Number = value; }
            get { return Number; }
        }

        private void Form1_Load(object sender, EventArgs e) {}

        private void onAddEmployer(object sender, EventArgs e) {
            if (add.Checked) {
                if (employer.Checked) {
                    OnAddEmployer();
                }
                else if (applicant.Checked) {
                    OnAddApplicant();
                }
                else if (skill.Checked) {
                    OnAddSkill();
                }
                else if (vacancy.Checked) {
                    OnAddVacancy();
                }
                else if (deal.Checked) {
                    OnMakeDeal();
                }
            }
            if (get.Checked) {
                prev.Visible = true;
                next.Visible = true;
                if (employer.Checked) {
                    OnGetEmployer();
                }
                else if (applicant.Checked) {
                    OnGetApplicant();
                }
                else if (skill.Checked) {
                    OnGetSkill();
                }
                else if (vacancy.Checked) {
                    OnGetVacancy();
                }
                else if (deal.Checked) {
                    OnGetDeal();
                }
            }
        }

        private void add_CheckedChanged(object sender, EventArgs e) {
            dataChoise.Text = "Choose data to add:";
            button.Text = "Add data";
            dataChoise.Visible = true;
            textBox1.ReadOnly = false;
            textBox2.ReadOnly = false;
            textBox3.ReadOnly = false;
            textBox4.ReadOnly = false;
            textBox5.ReadOnly = false;
            textBox6.ReadOnly = false;
            textBox7.ReadOnly = false;

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            prev.Visible = false;
            next.Visible = false;
        }

        private void get_CheckedChanged(object sender, EventArgs e) {
            dataChoise.Text = "Choose data to get:";
            button.Text = "Get data";
            dataChoise.Visible = true;
            textBox1.ReadOnly = true;
            textBox2.ReadOnly = true;
            textBox3.ReadOnly = true;
            textBox4.ReadOnly = true;
            textBox5.ReadOnly = true;
            textBox6.ReadOnly = true;
            textBox7.ReadOnly = true;
            comboBox1.Visible = false;
            comboBox2.Visible = false;
            comboBox3.Visible = false;
            comboBox4.Visible = false;
            groupBox1.Visible = false;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
        }

        private void employer_CheckedChanged(object sender, EventArgs e) {
            groupBox1.Visible = true;
            label1.Text = "Name";
            textBox1.Text = "";
            label2.Visible = true;
            label3.Visible = true;
            label4.Visible = true;
            textBox2.Visible = true;
            textBox3.Visible = true;

            comboBox2.Visible = false;
            label2.Text = "Address";
            textBox2.Text = "";
            label3.Text = "Telephone";
            textBox3.Text = "";
            label4.Text = "Activity"; //выпадающий список
            if (add.Checked) {
                comboBox1.DataSource = new List<string> { "sleep", "eat", "walk" };
                comboBox1.Visible = true;
                textBox4.Visible = false;
            }
            else if (get.Checked) {
                textBox4.Text = "";
                comboBox1.Visible = false;
                textBox4.Visible = true;
            }

            comboBox3.Visible = false;
            comboBox4.Visible = false;
            label5.Visible = false;
            textBox5.Visible = false;
            label6.Visible = false;
            textBox6.Visible = false;
            label7.Visible = false;
            textBox7.Visible = false;
        }

        private void applicant_CheckedChanged(object sender, EventArgs e) {
            groupBox1.Visible = true;
            label1.Text = "Name";
            textBox1.Text = "";
            label2.Visible = true;
            label2.Text = "Mid. Name";
            textBox2.Visible = true;
            textBox2.Text = "";
            label3.Visible = true;
            label3.Text = "Surname";
            textBox3.Visible = true;
            textBox3.Text = "";
            label4.Visible = true;
            label4.Text = "Activity";

            if (add.Checked) {
                comboBox1.DataSource = new List<string> { "sleep", "eat", "walk" };
                textBox4.Visible = false;
                comboBox1.Visible = true;
                comboBox2.DataSource = new List<string> { "cook", "typing", "foreign lang" };
                textBox5.Visible = false;
                comboBox2.Visible = true;
            }
            else if (get.Checked) {
                textBox4.Visible = true;
                textBox4.Text = "";
                comboBox1.Visible = false;
                textBox5.Visible = true;
                textBox5.Text = "";
                comboBox2.Visible = false;
            }

            comboBox3.Visible = false;
            comboBox4.Visible = false;
            label5.Visible = true;
            label6.Visible = true;
            textBox6.Visible = true;
            label5.Text = "Skills";
            label6.Text = "Residence";
            textBox6.Text = "";
            label7.Visible = false;
            textBox7.Visible = false;
        }

        private void skill_CheckedChanged(object sender, EventArgs e) {
            groupBox1.Visible = false;
            label1.Text = "Description";
            textBox1.Text = "";
            label2.Visible = false;
            textBox2.Visible = false;
            label3.Visible = false;
            textBox3.Visible = false;
            label4.Visible = false;
            textBox4.Visible = false;
            label5.Visible = false;
            textBox5.Visible = false;
            label6.Visible = false;
            textBox6.Visible = false;
            label7.Visible = false;
            textBox7.Visible = false;
            comboBox1.Visible = false;
            comboBox2.Visible = false;
            comboBox3.Visible = false;
            comboBox4.Visible = false;
            dataGridView1.Visible = true;
            dataGridView1.DataSource = SkillsDescripton;
        }

        private void vacancy_CheckedChanged(object sender, EventArgs e) {
            groupBox1.Visible = true;
            label2.Visible = true;
            label3.Visible = true;
            label4.Visible = true;
            label5.Visible = true;
            label6.Visible = true;
            label7.Visible = true;
            textBox2.Visible = true;
            textBox3.Visible = true;
            textBox4.Visible = true;
            textBox5.Visible = true;
            textBox6.Visible = true;
            textBox7.Visible = true;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            label1.Text = "Name";
            label2.Text = "Open Date";
            label3.Text = "Location";
            label4.Text = "Salary";
            label5.Text = "Skills";
            label6.Text = "Activity";
            comboBox1.Visible = false;
            comboBox2.Visible = false;

            if (add.Checked) {
                comboBox4.DataSource = new List<string> { "sleep", "eat", "walk" };
                textBox6.Visible = false;
                comboBox3.Visible = true;
                comboBox3.DataSource = new List<string> { "cook", "typing", "foreign lang" };
                textBox5.Visible = false;
                comboBox4.Visible = true;
            }
            else if (get.Checked) {
                textBox6.Visible = true;
                textBox6.Text = "";
                comboBox3.Visible = false;
                textBox5.Visible = true;
                textBox5.Text = "";
                comboBox4.Visible = false;
            }

            label7.Text = "Employer";
        }

        private void deal_CheckedChanged(object sender, EventArgs e) {
            groupBox1.Visible = true;
            label2.Visible = true;
            label3.Visible = true;
            textBox2.Visible = true;
            textBox3.Visible = true;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            label1.Text = "Applicant";
            label2.Text = "Employer";
            label3.Text = "Vacancy";
            label4.Visible = false;
            textBox4.Visible = false;
            label5.Visible = false;
            textBox5.Visible = false;
            label6.Visible = false;
            textBox6.Visible = false;
            label7.Visible = false;
            textBox7.Visible = false;
            // comboBox1.DataSource = new List<string> { "bla", "bro" };
            comboBox1.Visible = false;
            comboBox2.Visible = false;
            comboBox3.Visible = false;
            comboBox4.Visible = false;
        }

        private void next_Click(object sender, EventArgs e) {}

        private void button2_Click(object sender, EventArgs e) {
            Number++;
            if (employer.Checked) {
                OnGetEmployer();
            }
            else if (applicant.Checked) {
                OnGetApplicant();
            }
            else if (skill.Checked) {
                OnGetSkill();
            }
            else if (vacancy.Checked) {
                OnGetVacancy();
            }
            else if (deal.Checked) {
                OnGetDeal();
            }
        }

        private void button1_Click(object sender, EventArgs e) {
            Number--;
            if (employer.Checked) {
                OnGetEmployer();
            }
            else if (applicant.Checked) {
                OnGetApplicant();
            }
            else if (skill.Checked) {
                OnGetSkill();
            }
            else if (vacancy.Checked) {
                OnGetVacancy();
            }
            else if (deal.Checked) {
                OnGetDeal();
            }
        }
    }
}